﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Studio77.FunPeaceForWP7.Views
{
    public partial class IosPageViewer : UserControl
    {
        int Count { get; set; }
        int CurrentIndex { get; set; }

        public IosPageViewer()
        {
            CurrentIndex = 1;
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(IosPageViewer_Loaded);
        }

        public void SetCountAndCurrentIndex(int count, int index)
        {
            Count = count;
            CurrentIndex = index;
            UpdateUI();
        }

        void IosPageViewer_Loaded(object sender, RoutedEventArgs e)
        {
            this.Loaded -= new RoutedEventHandler(IosPageViewer_Loaded);
            UpdateUI();
        }

        private void UpdateUI()
        {
            if (Count > 0)
            {
                contentPanel.Children.Clear();
                for (int i = 1; i <= Count; i++)
                {
                    Ellipse ellipse = new Ellipse();
                    ellipse.Width = 10;
                    ellipse.Height = 10;
                    ellipse.StrokeThickness = 2;
                    Color whiteColor = Color.FromArgb(255, 255, 255, 255);
                    ellipse.Stroke = new SolidColorBrush(whiteColor);

                    if (i == CurrentIndex)
                    {
                        ellipse.Fill = new SolidColorBrush(whiteColor);
                    }
                    ellipse.Margin = new Thickness(10, 0, 10, 0);

                    contentPanel.Children.Add(ellipse);
                }
            }
        }
    }
}
